<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Test HTMLInputElement::valueAsDate binding.');

var input = document.createElement('input');
var date = new Date();

debug('Unsuppported type:');
input.type = 'text';
shouldBe('input.valueAsDate', 'null');
shouldThrow('input.valueAsDate = date');

debug('');
debug('Supported type:');
input.type = 'month';
input.value = '2009-12';
var valueAsDate = input.valueAsDate;
shouldBeTrue('valueAsDate != null');
shouldBe('typeof valueAsDate', '"object"');
shouldBe('valueAsDate.constructor.name', '"Date"');

debug('Sets an Epoch Date:');
date.setTime(0);
input.valueAsDate = date;
shouldBe('input.value', '"1970-01"');
shouldBe('input.valueAsDate.getTime()', '0');
debug('Sets a number 0:');
shouldThrow('input.valueAsDate = 0');
debug('Sets other types:');
input.value = '1970-01';
input.valueAsDate = null;
shouldBe('input.value', '""');
input.valueAsDate = undefined;
shouldBe('input.value', '""');
shouldThrow('input.valueAsDate = document');
</script>
</body>
</html>
